package com.platform.core.repository;

import com.platform.comm.repository.CustomBaseRepository;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.core.types.dsl.StringPath;
import com.platform.core.entity.QSysDepart;
import com.platform.core.entity.SysDepart;
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.querydsl.binding.SingleValueBinding;

/**
 * Description: 部门-JPA接口
 *
 * @author libin Created on 2019/7/18
 **/
public interface SysDepartRepository extends CustomBaseRepository<SysDepart, String>, QuerydslBinderCustomizer<QSysDepart> {

    /**
     * 查询
     * @param bindings QuerydslBindings
     * @param root QSysDepart
     */
    @SuppressWarnings("NullableProblems")
    @Override
    default void customize(QuerydslBindings bindings, QSysDepart root) {
        bindings.excluding(root.status);
        bindings.bind(String.class)
                .first((SingleValueBinding<StringPath, String>) StringExpression::containsIgnoreCase);
        bindings.bind(root.parentId).first(StringExpression::eq);
    }
}
